//
//  ViewController.swift
//  swift-懒加载
//
//  Created by zq on 2020/10/26.
//

import UIKit

class ViewController: UIViewController {
    
    // var lable = DemoLable() 如果不进行懒加载 那么这个view是优先于viewDidload 加载
    // 懒加载:这个当调用这个view时,再加载
//    lazy var lable : DemoLable = DemoLable()
    
    //懒加载还可以这么写:不推荐
    lazy var lable = { ()->DemoLable in
        let l = DemoLable()
        return l
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        
        lable.text = "hello"
        lable.textColor = UIColor.black
        lable.center = view.center
        lable.sizeToFit()
        
        self.view.addSubview(lable)
    }


}

